Ext.define('DCApp.store.Navigation', {
    extend: 'Ext.data.TreeStore',
    alias: 'store.navigation',

    constructor: function(config) {
        var me = this,
            queryParams = Ext.Object.fromQueryString(location.search),
            charts = ('charts' in queryParams) && !/0|false|no/i.test(queryParams.charts);

        me.callParent([Ext.apply({
            root: {
                text: '全部',
                id: 'all',
                expanded: true,
                children:  me.getNavItems()
            }
        }, config)]);
    },

    addIconClasses: function (items) {
        for (var item, i = items.length; i-- > 0; ) {
            item = items[i];

            if (!('iconCls' in item)) {
                item.iconCls = 'icon-' + item.id;
            }

            if (!('glyph' in item)) {
                // sets the font-family
                item.glyph = '32@Sencha-Examples';
            }

            if (item.children) {
                this.addIconClasses(item.children);
            }
        }

        return items;
    },


    getNavItems: function() {
        return this.addIconClasses([

            {
                id: 'dg_zw',
                expanded: true,
                text: '中文文稿',
                leaf: false,
                description: '用于中文网站的稿件',
                children: [
                    {id: 'reliclist', text: '文物', leaf: true },
                    {id: 'buildinglist', text: '建筑', leaf: true },
					{id:'cbw', text: '出版物', leaf: false, expanded: true,
	                children: [
	                 	{id: 'cataloglist', text: '期刊', leaf: true },
	                    {id: 'booklist', text: '图书', leaf: true }
	                ]
                    },                   
                    {id: 'lemmalist', text: '词条', leaf: true },
	                {id: 'figurelist', text: '人物', leaf: true },
	                {id: 'contributionlist', text: '捐献', leaf: true },
	                {id: 'doclist',idd:'docdetail', text: '其他', leaf: true }	          
                ]
            },
            {
                id: 'dg_zy',
                expanded: true,
                text: '资源',
                leaf: false,
                description: '包括用于网站群的各种资源',
                children: [
                    {id: 'imglist', text: '影像', leaf: true },
                    {id: 'giftlist', text: '墙纸', leaf: true },
                    {id: 'giftlisthk', text: '贺卡', leaf: true },
                    {id: 'giftlistpb', text: '屏保', leaf: true },
                    {id: 'avlist', text: '音视频', leaf: true },
                    {id: 'attachlist', text: '附件', leaf: true },
                    {id: 'thesislist', text: 'PDF论文', leaf: true },
                    {id: 'aglist', text: '生僻字', leaf: true }
                ]
            }, 
            { 
            	id: 'dg_yw_wg', 
            	expanded: true,
            	text: '英文文稿', 
            	leaf: false,
            	description: '用于英文网站的稿件',
            	children: [
            	    {id: 'relicuklist', text: '文物', leaf: true },
            	    {id: 'figureuklist', text: '人物', leaf: true },
            	    {id: 'contributionuklist',idd:'contributionukdetail', text: '捐献', leaf: true },
   	                {id: 'docuklist',idd:'docukdetail', text: '其他', leaf: true }
                   ]
            },
                                            
            {
                text: '系统管理',
                id: 'sz',
                expanded: true,
                description: '对系统的基表、用户及权限的设置',
                children: [
                    { id: 'ccsynclist', text: '日志', leaf: true },
                    { id: 'payfactorlist', text: '稿酬规则', leaf: true },
                    { id: 'paylist', text: '稿酬确认', leaf: true },
                    { id: 'payhistorylist', text: '稿酬发放', leaf: true },
                    
                    { id: 'ugrouplist', text: '用户组', leaf: true },
                    { id: 'sz_yh', 
                    	text: '用户', 
                    	leaf: false,
                    	description: '本系统涉及的用户',
                        children: [
                           {id: 'uuserlist', text: '本系统用户', leaf: true },
                           {id: 'sz_yh_syz', text: '摄影者', leaf: true },
                           {id: 'baseauthorlist', text: '外单位人员', leaf: true }
                       ] 
                    },
                    { id: 'sz_xx', 
                    	text: '选项', 
                    	leaf: false,
                    	description: '用于文稿及资源的分类选项',
                        children: [
                           {id: 'sz_xx_gjqy', text: '古建区域', leaf: true },
                           {id: 'sz_xx_gjfl', text: '古建分类', leaf: true },
                           {id: 'sz_xx_wgfl', text: '文稿分类', leaf: true },
                           {id: 'sz_xx_zc', text: '职称', leaf: true }
                       ] 
                    }
                ]
            }
        ]);
    }
});
